var express = require("express");
var request = require('request');
var router = express.Router();

router.post("/api/v1/secCheck", async (req, res) => {
  let url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxa98b1ed9338a9035&secret=4f675d943bc7912bdd6e0a8d0f76ff88"
  let access_token = ''
    console.log('xxxxxxxxxx')
    request(url, function (error, response, body) {
      console.log(JSON.parse(body))
      access_token = JSON.parse(body).access_token
      let url = 'https://api.weixin.qq.com/wxa/msg_sec_check?access_token='+access_token
        request.post(
          {
              url: url,
            json: true,
              body:
              {
                content: req.body.text
              }
          }, function(err, httpResponse, body){
            console.log(body)
            res.json(body)
          })
     });
  
  
});

// 导出模块（在 app.js 中引入）
module.exports = router;